import models from '@/database/sequelize'
const User = models.users 
export class Login {
    static findByUserName(username) { // 查找所有用户
        return User.findAll({
            where: {
                username: username
            }
        })
    }

    static findByUserNameAndPassword(username, password) { // 查找用户
        return User.findOne({
            where: {
                username,
                password
            }
        })
    }
}

export class Register {
    static registerNewUser({
        password,
        username,
        nickname,
        phone,
        role
    }) {
        return User.create({
            password,
            username,
            nickname,
            phone,
            role
        });
    }
}

export class Update {
    static updateUserInfo(id) {
        return User.findOne({
            where: {
                id
            }
        })
    }
}

export class Logout {
    static LogoutUser(id) {
        return User.findOne({
            where: {
                id
            }
        })
    }
}
